package com.ming.MathTest;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Auther: tangC
 * @Date: 2020/7/14 10:51
 * @Description:
 */
public class SortTest {



    // 冒泡排序
    public static void bubbleSort(List<Integer> list){
       for (int x = 0;x<list.size();x++){
           for (int y=0;y<list.size()-1-x;y++){
               if (list.get(y)>list.get(y+1)){
                   int temp = list.get(y+1);
                   list.set(y+1,list.get(y));
                   list.set(y,temp);
               }
           }
       }

    }

    public static void main(String[] args) {
        List<Integer> list = new ArrayList<Integer>();
        int x = 0;
        while (x<10){
            list.add((int) (Math.random()*100));
            x++;
        }
        bubbleSort(list);
        System.out.println(list);
    }
}
